<style>
	.layui-form-label {
		width: 90px;
	}
</style>
<!--页面主要内容-->
<main class="lyear-layout-content">

	<div class="container-fluid p-t-15">

		<div class="row">

			<div class="col-lg-12">
				<div class="card">

					<div class="card-toolbar d-flex flex-column flex-md-row">
						<div class="toolbar-btn-action">

							<a class="btn btn-primary" href="{:url('admin/order/order')}"><i
									class="mdi mdi-check m-r-5"></i>返回</a>

						</div>

					</div>

					<ul class="nav nav-tabs page-tabs pt-2 pl-3 pr-3">
						<li class="nav-item"> <a class="nav-link active" style="cursor: pointer;">售后详情</a> </li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active">

							<div class="layui-form-item">
								<label class="layui-form-label">退货人</label>
								<div class="layui-input-block">
									<input type="text" disabled value="{$address['consignee']}" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">手机号码</label>
								<div class="layui-input-block">
									<input type="text" disabled value="{$address['mobile']}" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">联系地址</label>
								<div class="layui-input-block">
									<input type="text" disabled value="{$address['address_text']}" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">订单商品</label>
								<div class="layui-input-block">
									<input type="text" disabled value="{$productStr}" class="layui-input">
								</div>
							</div>
							{foreach $productImgArr as $key => $item}
							{foreach $item as $val}
							<div class="layui-form-item">
								<label class="layui-form-label">商品图片</label>
								<div class="layui-input-block">
									<img src="{$val}" alt="" height="200">
								</div>
							</div>
							{/foreach}
							{/foreach}
							<div class="layui-form-item">
								<label class="layui-form-label">订单总价</label>
								<div class="layui-input-block">
									<input type="text" disabled value="{$order['total']}" class="layui-input">
								</div>
							</div>

							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">退货理由</label>
								<div class="layui-input-block">
									<textarea disabled name="desc" class="layui-textarea">{$order['comment']}</textarea>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">退货图片</label>
								<div class="layui-input-block">
									{foreach $order['proimg_cdn'] as $item}
									<img src="{$item}" alt="" height="200">
									{/foreach}
								</div>
							</div>


							<div class="layui-form-item">
								<div class="layui-input-block">
									<button class="layui-btn btnShou" lay-filter="formDemo" data-id="{$order['id']}" data-status="-1" data-userid="{$user['id']}">同意退款</button>
									<button class="layui-btn btnShou" lay-filter="formDemo" data-id="{$order['id']}" data-status="-3" data-userid="{$user['id']}">拒绝退款</button>
								</div>
							</div>

						</div>
					</div>

				</div>
			</div>

		</div>

	</div>

</main>
<script type="text/javascript">
	layui.use(['layer'], function() {
		layer = layui.layer

		// 删除分类
		$('.btnShou').click(function() {

			let id = $(this).data('id');
			
			let status = $(this).data('status');
			
			let userid = $(this).data('userid');

			$.ajax({
				type: 'post',
				url: `{:url('admin/order/refuse')}`,
				data: {
					id,
					status,
					userid
				},
				dataType: 'json',
				success: function(res) {
					if (res.code === 1) {
						layer.msg(res.msg, {
							icon: 1
						}, function() {
							location.href = res.url;
						})
					} else {
						layer.msg(res.msg, {
							icon: 5
						})
					}
				}
			})

		})

	})
</script>
